package hadoop.mr01;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class partiton_mapper extends Mapper<LongWritable, Text,Text,LongWritable> {
    private Text f1 = new Text();
    private LongWritable num = new LongWritable();

    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, LongWritable>.Context context) throws IOException, InterruptedException {
        String[] values = value.toString().split(",");
        String foodKind = values[0]; // 菜品名称 --> 海鲜
        f1.set(foodKind);
        num.set(1);
        // 海鲜,1
        context.write(f1, num);
    }
}
